package com.sam.im.heiqun.uis.activities;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.sam.im.heiqun.R;
import com.yuyh.library.uis.activitys.BaseSwipeBackActivity;

import butterknife.BindView;
import butterknife.OnClick;

public class SexSelectActivity extends BaseSwipeBackActivity implements RadioGroup.OnCheckedChangeListener {

    @BindView(R.id.sex_select_group)
    RadioGroup selectGroup;
    @BindView(R.id.left_back)
    ImageView backImg;
    @BindView(R.id.right_commit)
    TextView commit;
    @BindView(R.id.center_title)
    TextView title;
    @BindView(R.id.select_male)
    RadioButton male;

    String sex ;


    @Override
    protected String getTitleText() {
        title.setText(R.string.select_sex);
        return getResources().getString(R.string.select_sex);
    }

    @Override
    protected void initViews(Bundle savedInstanceState) {
        selectGroup.setOnCheckedChangeListener(this);
        sex = getIntent().getStringExtra("sex");
        if (getString(R.string.male).equals(sex)) {
            male.setChecked(true);
        }else {
            sex = getString(R.string.female);
            male.setChecked(false);
        }
    }

    @Override
    public int getContentViewId() {
        return R.layout.activity_sex_select;
    }

    @OnClick({R.id.left_back,R.id.right_commit})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.left_back:
                finish();
                break;
            case R.id.right_commit:
                //提交性别数据
                Intent data = new Intent();
                data.putExtra("sex",sex);
                setResult(RESULT_OK, data);
                finish();
                break;
        }
    }

    @Override
    public void onCheckedChanged(RadioGroup group, int checkedId) {
        if (checkedId== R.id.select_female) {
            sex = getResources().getString(R.string.female);
        }else {
            sex =getResources().getString(R.string.male);
        }
    }
}
